﻿using System;
using Brjnk.GpxExplorer.Computing;

namespace Brjnk.GpxExplorer.Workspace.Searching
{
    public class SearchConfiguration
    {
        private double maxPhotoDistance = 300;

        public double MaxPhotoDistance
        {
            get { return maxPhotoDistance; }
            set
            {
                if (isSealed) throw new InvalidOperationException("SearchConfiguration již nelze upravovat");
                maxPhotoDistance = value;
            }
        }

        private double maxPushpinDistance = 1000;

        public double MaxPushpinDistance
        {
            get { return maxPushpinDistance; }
            set
            {
                if (isSealed) throw new InvalidOperationException("SearchConfiguration již nelze upravovat");
                maxPushpinDistance = value;
            }
        }

        private double searchAgainPhotoDistance = 1000;

        public double SearchAgainPhotoDistance
        {
            get { return searchAgainPhotoDistance; }
            set
            {
                if (isSealed) throw new InvalidOperationException("SearchConfiguration již nelze upravovat"); searchAgainPhotoDistance = value;
            }
        }

        private double searchAgainPushpinDistance = 2000;

        public double SearchAgainPushpinDistance
        {
            get { return searchAgainPushpinDistance; }
            set
            {
                if (isSealed) throw new InvalidOperationException("SearchConfiguration již nelze upravovat"); searchAgainPushpinDistance = value;
            }
        }

        private double maxWaypointDistance = 300;

        public double MaxWaypointDistance
        {
            get { return maxWaypointDistance; }
            set
            {
                if (isSealed) throw new InvalidOperationException("SearchConfiguration již nelze upravovat");
                maxWaypointDistance = value;
            }
        }

        private double searchAgainWaypointDistance = 1000;

        public double SearchAgainWaypointDistance
        {
            get { return searchAgainWaypointDistance; }
            set
            {
                if (isSealed) throw new InvalidOperationException("SearchConfiguration již nelze upravovat");
                searchAgainWaypointDistance = value;
            }
        }

        private bool searchPhotosInPathGaps = true;

        public bool SearchPhotosInPathGaps
        {
            get { return searchPhotosInPathGaps; }
            set
            {
                if (isSealed) throw new InvalidOperationException("SearchConfiguration již nelze upravovat");
                searchPhotosInPathGaps = value;
            }
        }

        private bool searchPushpinsInPathGaps = true;

        public bool SearchPushpinsInPathGaps
        {
            get { return searchPushpinsInPathGaps; }
            set
            {
                if (isSealed) throw new InvalidOperationException("SearchConfiguration již nelze upravovat");
                searchPushpinsInPathGaps = value;
            }
        }

        private bool searchWaypointsInPathGaps = true;

        public bool SearchWaypointsInPathGaps
        {
            get { return searchWaypointsInPathGaps; }
            set
            {
                if (isSealed) throw new InvalidOperationException("SearchConfiguration již nelze upravovat");
                searchWaypointsInPathGaps = value;
            }
        }

        private bool isSealed;

        public void Seal()
        {
            isSealed = true;
        }

        public FindPositionArgs GetPhotoSearchArgs()
        {
            return new FindPositionArgs(MaxPhotoDistance, SearchAgainPhotoDistance, SearchPhotosInPathGaps);
        }

        public FindPositionArgs GetWaypointSearchArgs()
        {
            return new FindPositionArgs(MaxWaypointDistance, SearchAgainWaypointDistance, SearchWaypointsInPathGaps);
        }
    }
}